#ifndef QCUSTOMCALENDARWIDGET_H
#define QCUSTOMCALENDARWIDGET_H

#include <QCalendarWidget>
#include <QObject>

#include <QCalendarWidget>
#include <QMouseEvent>

#include <QDebug>

class QPushButton;
class QLabel;
class QCustomCalendarWidget : public QCalendarWidget
{
    Q_OBJECT

public:
    //判断是开始日历还是结束日历
    int startFilg_ = 1;

    QCustomCalendarWidget(QWidget *parent,int startFilg = 1);
    ~QCustomCalendarWidget();

    void setRangeDate(const QDate& data);

private:
    void initControl();
    void initTopWidget();
    //void initBottomWidget();


    void setDataLabelTimeText(int year, int month);

signals:
    void signalSetCalendarTime(const QDate& data);

private slots:
    void onbotttonClicked();

protected:

    void mousePressEvent(QMouseEvent *event) override {

        // 调用 update() 强制重绘
        update();

        // 继续处理鼠标事件
        QCalendarWidget::mousePressEvent(event);

        // 在点击后的操作中，你可以选择其他逻辑
        // 例如：更新某个状态，或标记某个日期等
    }

    void paintCell(QPainter *painter, const QRect &rect, const QDate &date) const;


private:

    QDate dateRange_;

    QPushButton* m_leftYearBtn;
    QPushButton* m_leftMonthBtn;

    QPushButton* m_rightYearBtn;
    QPushButton* m_rightMonthBtn;

    QPushButton* m_ensureBtn;
    QPushButton* m_toDayBtn;

    QLabel* m_dataLabel;
};

#endif // QCUSTOMCALENDARWIDGET_H
